#include<stdio.h>

struct point
{
    int x;
    int y;
};

struct point find(int arr[][3],int row,int col,int n)
{
    int x=0;
    int y=col-1;
    struct point p={-1,-1};
    while(x<row&&y>=0)
    {
        if(n<arr[x][y])  y--;
        else if(n>arr[x][y])   x++;
        else
        {
           p.x=x;
           p.y=y;
           return p;
        }
    }
    return p;
}


int main()
{
    int n=0;
    scanf("%d",&n);
    int arr[3][3]={1,2,3,4,5,6,7,8,9};
    struct point ret=find(arr,3,3,n);
    printf("%d %d",ret.x,ret.y);
}